home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Telecom / Terminal Programs / Terminal 2.0 / Srcs / TerminalOptions.c < prev    next >
Text File  |  1990-11-20  |  4KB  |  132 lines

  1. /*
  2.     Terminal 2.0
  3.     "TerminalOptions.c"
  4. */
  5.  
  6. #ifdef THINK_C
  7. #include "MacHeaders"
  8. #endif
  9. #ifdef applec
  10. #pragma load ":(Objects):MacHeadersMPW"
  11. #pragma segment Options
  12. #endif
  13.  
  14. #include "Options.h"
  15. #include "Strings.h"
  16. #include "Utilities.h"
  17. #include "Text.h"
  18. #include "Main.h"
  19. #include "Procedure.h"
  20. #include "MySF.h"
  21. #include "Document.h"
  22.  
  23. #define B_OK            1        /* "Ok" button */
  24. #define B_CANCEL        2        /* "Cancel" button */
  25. #define C_SAVE            3        /* Save checkbox */
  26. #define    C_AUTOLF        4        /* Auto LF checkbox */
  27. #define C_ECHO_LOCAL    5        /* Local echo check box */
  28. #define C_ECHO_REMOTE    6        /* Remote echo check box */
  29. #define T_ECHO            7        /* Frame */
  30. #define U_ECHO            8
  31. #define C_START_ENABLE    9        /* Enable autostart script */
  32. #define B_START_SELECT    10        /* Select autostart script */
  33. #define T_START_PATH    11        /* Autostart script path name */
  34. #define T_START            12        /* Frame */
  35. #define U_START            13
  36. #define U_TITLELINE        15        /* Underline */
  37.  
  38. /* ----- Terminal options dialog --------------------------------------- */
  39.  
  40. void TerminalOptions(void)
  41. {
  42.     register DialogPtr dialog;
  43.     short number;
  44.     Byte str[256];
  45.     SFReply sfr;
  46.     short volume;
  47.     long directory;
  48.     Byte name[32];
  49.  
  50.     CenterDialog('DLOG', DLOG_TERMINAL);
  51.     if (!(dialog = GetNewDialog(DLOG_TERMINAL, 0, (WindowPtr)-1L)))
  52.         return;
  53.     SetUserItem(dialog, U_ECHO, (ProcPtr)DrawUserFrame);
  54.     SetUserItem(dialog, U_START, (ProcPtr)DrawUserFrame);
  55.     SetUserItem(dialog, U_TITLELINE, (ProcPtr)DrawUserLine);
  56.     SetCheck(dialog, C_AUTOLF, Settings.autoLF);
  57.     SetCheck(dialog, C_ECHO_LOCAL, Settings.localEcho);
  58.     SetCheck(dialog, C_ECHO_REMOTE, Settings.echo);
  59.     SetCheck(dialog, C_SAVE, Settings.save);
  60.     volume = Settings.startVolume;
  61.     directory = Settings.startDirectory;
  62.     if (*Settings.startName) {
  63.         SetCheck(dialog, C_START_ENABLE, TRUE);
  64.         memcpy(name, Settings.startName, *Settings.startName + 1);
  65. #ifdef FULLPATH
  66.         Pathname(str, volume, directory);
  67. #else
  68.         *str = 0;
  69. #endif
  70.         Append(str, name);
  71.     } else {
  72.         SetCheck(dialog, C_START_ENABLE, FALSE);
  73.         *name = *str = 0;
  74.     }
  75.     SetEText(dialog, T_START_PATH, str);
  76.     ShowWindow(dialog);
  77.     do {
  78.         ModalDialog(OutlineFilter, &number);
  79.         switch(number) {
  80.             case B_OK:
  81.                 if (!GetCheck(dialog, C_START_ENABLE)) {
  82.                     volume = 0;
  83.                     directory = 0;
  84.                     *name = 0;
  85.                 }
  86.                 if (volume != Settings.startVolume ||
  87.                     directory != Settings.startDirectory ||
  88.                     !EqualString(name, Settings.startName, FALSE, FALSE)) {
  89.                     Settings.startVolume = volume;
  90.                     Settings.startDirectory = directory;
  91.                     memcpy(Settings.startName, name, *name + 1);
  92.                     VolumeId(Settings.startVName, &Settings.startVolume);
  93.                     Settings.dirty = TRUE;
  94.                 }
  95.                 TerminalSetup(GetCheck(dialog, C_ECHO_LOCAL),
  96.                     GetCheck(dialog, C_ECHO_REMOTE),
  97.                     GetCheck(dialog, C_AUTOLF),
  98.                     GetCheck(dialog, C_SAVE));
  99.                 break;
  100.             case B_CANCEL:
  101.                 break;
  102.             case B_START_SELECT:
  103.                 MySFGetFile(MyString(STR_G, G_SCRIPT),
  104.                     MyString(STR_G, G_SUFFIX), 1, &TEXT,
  105.                     &sfr, 0);
  106.                 RedrawDocument();
  107.                 if (sfr.good) {
  108.                     volume = -SFSaveDisk;
  109.                     directory = CurDirStore;
  110.                     memcpy(name, sfr.fName, *sfr.fName + 1);
  111. #ifdef FULLPATH
  112.                     Pathname(str, volume, directory);
  113. #else
  114.                     *str = 0;
  115. #endif
  116.                     Append(str, name);
  117.                     SetEText(dialog, T_START_PATH, str);
  118.                     SetCheck(dialog, C_START_ENABLE, TRUE);
  119.                 }
  120.                 break;
  121.             case C_SAVE:
  122.             case C_AUTOLF:
  123.             case C_ECHO_LOCAL:
  124.             case C_ECHO_REMOTE:
  125.             case C_START_ENABLE:
  126.                 ToggleCheckBox(dialog, number);
  127.                 break;
  128.         }
  129.     } while (number != B_OK && number != B_CANCEL);
  130.     DisposDialog(dialog);
  131. }
  132.